﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;

void test01() {
	const char * p = "翠花";
	const char* &p1 = p;
	cout << "test01 " << p1 << endl; // 
}
// c语言二重指针方式分配内存
void func2(char** tmp) {
	char * p = (char*)malloc(64);
	memset(p, 0, 64);
	strcpy(p, "小花");
	*tmp = p;
}
void test02() {
	char * str;
	func2(&str);
	cout << "test02 " << str << endl;
}

// c++指针引用方式分配内存 
void func3(char* &tmp) { // 引用传递 
	char * p = (char*)malloc(64);
	memset(p, 0, 64);
	strcpy(p, "酸菜");
	tmp = p;
}
void test03() {
	char * str;
	func3(str);
	cout << "test03 " << str << endl;
}

int main()
{
	test01();
	test02();
	test03();

	system("pause");
	return EXIT_SUCCESS;
}